package com.example;

import com.example.config.AppConfig;
import com.example.service.OrderService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {
    public static void main(String[] args) {
        // 现在可以正常访问 public 的 AppConfig 类
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext(AppConfig.class);

        OrderService orderService = context.getBean(OrderService.class);

        try {
            orderService.add("手机", 2);
        } catch (Exception e) {
            System.out.println("add 方法执行异常：" + e.getMessage());
        }

        try {
            orderService.delete("耳机");
        } catch (Exception e) {
            System.out.println("delete 方法执行异常：" + e.getMessage());
        }

        orderService.find("手机");

        context.close();
    }
}